package com.gimi.cloud.jimi.client.controller.moreInfo;

import com.alibaba.fastjson.JSON;
import com.gimi.cloud.jimi.client.service.moreInfo.DebitcardBankcodeService;
import com.gimi.cloud.jimi.common.enums.ResponseCodeEnum;
import com.gimi.cloud.jimi.common.utils.JsonUtil;
import com.gimi.cloud.jimi.common.utils.reqhead.Response;
import com.gimi.cloud.jimi.common.utils.reqhead.Util;
import com.gimi.cloud.jimi.dto.app.moreInfo.DebitcardBankcodeDTO;
import com.gimi.cloud.jimi.dto.app.moreInfo.DebitcardLoginDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;


/**
 * 蜂巢信用卡相关服务
 */
@RestController
@RequestMapping(value = "/moreInfo")
public class DebitcardBankcodeController {

	private static final Logger log = LoggerFactory.getLogger(DebitcardBankcodeController.class);

	private DebitcardBankcodeService debitcardBankcodeService;
    @Autowired
	public DebitcardBankcodeController(DebitcardBankcodeService debitcardBankcodeService) {
		this.debitcardBankcodeService = debitcardBankcodeService;
	}

	/**
	 * 获取工资卡信息
	 * @param response
	 */
	@RequestMapping(value = "/getSalaryCardInfo")
	public void getSalaryCardInfo(HttpServletResponse response) throws Exception {
		log.info("获取工资卡信息入参：");
		Response resp = new Response();
		resp.setResponseCode(ResponseCodeEnum.SUCCESSED,"该服务接口暂时未开通！！");
		Util.sendResponse(JsonUtil.toJSONStringWithDateFormatYYYYMMDDHHMMSS(resp), response);
	}

	/**
	 * 获取蜂巢工资卡登陆参数
	 * @param debitcardBankcodeDTO
	 * @param response
	 */
	@RequestMapping(value = "/getDebitcardLoginParameter")
	public void getDebitcardLoginParameter(@RequestBody DebitcardBankcodeDTO debitcardBankcodeDTO, HttpServletResponse response){
		log.info("获取银行登陆参数,入参"+debitcardBankcodeDTO);
		Response responsedata = debitcardBankcodeService.getDebitcardLoginParameter(debitcardBankcodeDTO);
		Util.sendResponse(JSON.toJSONString(responsedata), response);
	}

	/**
	 * 蜂巢工资卡登陆
	 * @param debitcardBankcodeDTO
	 * @param response
	 */
	@RequestMapping(value = "/getDebitcardLogin")
	public void getDebitcardLogin(@RequestBody DebitcardBankcodeDTO debitcardBankcodeDTO, HttpServletResponse response){
		log.info("获取银行登陆参数,入参"+debitcardBankcodeDTO);
		Response responsedata = debitcardBankcodeService.getCreditcardLoginLogin(debitcardBankcodeDTO);
		Util.sendResponse(JSON.toJSONString(responsedata), response);
	}

	/**
	 * 蜂巢工资卡登验证码提交接口
	 * @param debitcardLoginDTO
	 * @param response
	 */
	@RequestMapping(value = "/subDebitcardValidCode")
	public void subFengchaoEmailValidCode(@RequestBody DebitcardLoginDTO debitcardLoginDTO, HttpServletResponse response){
		log.info("蜂巢工资卡登验证码提交接口,入参"+debitcardLoginDTO);
		Response responsedata = debitcardBankcodeService.subFengchaoEmailValidCode(debitcardLoginDTO);
		Util.sendResponse(JSON.toJSONString(responsedata), response);
	}

	/**
	 * 刷新蜂巢工资卡登验证码接口
	 * @param debitcardLoginDTO
	 * @param response
	 */
	@RequestMapping(value = "/refreshDebitcardValidcode")
	public void refreshDebitcardValidcode(@RequestBody DebitcardLoginDTO debitcardLoginDTO, HttpServletResponse response){
		log.info("蜂巢工资卡登验证码提交接口,入参"+debitcardLoginDTO);
		Response responsedata = debitcardBankcodeService.refreshDebitcardValidcode(debitcardLoginDTO);
		Util.sendResponse(JSON.toJSONString(responsedata), response);
	}
}
